package com.hu.video.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.jdbc.core.JdbcTemplate;
import java.util.*;

@RestController
@RequestMapping("/api/video")
public class VideoCommentCountController {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @GetMapping("/commentCount")
    public List<Map<String, Object>> getVideoCommentCounts() {
        String sql = "SELECT video_id, COUNT(*) AS commentCount FROM social_comment GROUP BY video_id";
        List<Map<String, Object>> result = jdbcTemplate.queryForList(sql);
        return result;
    }
}
